//
//  YDUserLogoutTableViewCell.m
//  IngCard
//
//  Created by kf on 2017/8/9.
//  Copyright © 2017年 IngDan. All rights reserved.
//

#import "YDUserLogoutTableViewCell.h"
#import "YDAccountManager.h"
#import "LinkedInHelper.h"


@implementation YDUserLogoutCellDataSource

-(Class) viewClass
{
    return [YDUserLogoutTableViewCell class];
}

@end

@interface YDUserLogoutTableViewCell()
@property(nonatomic, strong) UIButton *logoutButton;
@end

@implementation YDUserLogoutTableViewCell

+(CGFloat)viewHeight:(YDUserLogoutCellDataSource *) dataSource
{
    return dataSource.height ?: 240;
}

-(void) initSubviews
{
    [super initSubviews];
    
    [self.contentView addSubview:self.logoutButton];
    [self.logoutButton makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.contentView);
        make.top.equalTo(self.contentView).offset(183);
        make.width.equalTo(312);
        make.height.equalTo(49);
    }];
}

- (void)logoutButtonAction:(UIButton *)btn
{
    [ACCOUNT loginoutOnComplete:^(BOOL success, NSString *msg) {
        
    }];
    
    [[LinkedInHelper sharedInstance] logout];
}


- (UIButton *)logoutButton
{
    if (!_logoutButton)
    {
        _logoutButton = [[UIButton alloc] init];
        _logoutButton.frame = CGRectMake(0, 0, 312, 49);
        _logoutButton.layer.cornerRadius = 6;
        _logoutButton.backgroundColor = UIColorMake(248, 107, 107);
        _logoutButton.titleLabel.font = UIFontMake(17);
        [_logoutButton setTitle:@"退出登录" forState:UIControlStateNormal];
        _logoutButton.layer.masksToBounds = YES;
        [_logoutButton addTarget:self
                          action:@selector(logoutButtonAction:)
                forControlEvents:UIControlEventTouchUpInside];
    }
    return _logoutButton;
}


@end
